package com.budwk.app.common.rocketmq.rmqmsg;

import com.budwk.app.common.rocketmq.RocketMQServer;
import com.budwk.starter.common.openapi.annotation.*;
import com.budwk.starter.common.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.producer.SendResult;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.POST;

@IocBean
@At("/platform/producerexample")
@ApiDefinition(tag = "消息队列test")
@Slf4j
public class ProducerExampleController {
    @Inject
    RocketMQServer rocketMQServer;

    @At("/rockeetmqtest")
    @Ok("json")
    @ApiOperation(name = "消息队列test")
    @POST
    public Result<?> rockeetmqtest() {
        SendResult result=null;
        try {
            result= rocketMQServer.send("MyTopicTest","TAG1", "test".getBytes(),1000 * 100);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return Result.data(result);

    }



}
